//
//  TRRequestManager.m
//  iOSBaseFramework
//
//  Created by user on 2020/6/16.
//  Copyright © 2020 com.taylor. All rights reserved.
//

#import "TRRequestManager.h"




static NSString *baseUrl = @"custom api url";

@implementation TRRequestManager

+ (AFHTTPSessionManager *) shareHTTPManage {
    static AFHTTPSessionManager *manager = nil;
    static dispatch_once_t once;
    dispatch_once(&once, ^(void) {
        manager = [[AFHTTPSessionManager alloc] initWithBaseURL:[NSURL URLWithString:baseUrl]];
        manager.responseSerializer = [AFJSONResponseSerializer serializer];
        
        manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", @"text/html", nil];
    });
    return manager;
}


+ (AFURLSessionManager *) shareTaskManage{
    NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration];
    return [[AFURLSessionManager alloc] initWithSessionConfiguration:config];
}


+ (AFHTTPSessionManager *) createHttpManagerWithURL:(NSString *)url {
    static AFHTTPSessionManager *manager = nil;
    static dispatch_once_t once;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        manager = [[AFHTTPSessionManager alloc] initWithBaseURL:[NSURL URLWithString:url]];
        manager.requestSerializer = [AFHTTPRequestSerializer serializer];
        manager.responseSerializer = [AFJSONResponseSerializer serializer];
    });
    return manager;
}

@end
